﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using SES.CMS.DO;
using SES.CMS.BL;

namespace SES.CMS
{
    public partial class DoiMK : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                MasterPage mt = this.Master as MasterPage;
                TextBox txt = mt.FindControl("txtTK") as TextBox;
                txt.Text = String.Empty;

                if (Session["IDDN"] == null)
                    Response.Redirect("/Default.aspx");
            }
        }

        protected void btnDongY_Click(object sender, EventArgs e)
        {
            ClientLoginDO obj = new ClientLoginBL().Select(new ClientLoginDO { ClientLoginID = int.Parse(Session["IDDN"].ToString()) });
            if (txtold.Text == obj.Password)
            {
                obj.Password = Ultility.EncryptMd5(txtnew2.Text);
                new ClientLoginBL().Update(obj);
                Ultility.Alert("Thay đổi mật khẩu thành công!", "/ThongTin.aspx");
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("/Default.aspx");
        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            ClientLoginDO obj = new ClientLoginBL().Select(new ClientLoginDO { ClientLoginID = int.Parse(Session["IDDN"].ToString()) });
            if (Ultility.EncryptMd5(txtold.Text) == obj.Password)
            {
                obj.Password = Ultility.EncryptMd5(txtnew2.Text);
                new ClientLoginBL().Update(obj);
                Ultility.Alert("Thay đổi mật khẩu thành công!", "/ThongTin.aspx");
            }
            else
            {
                Ultility.Alert("Pass ko đúng!");
            }
        }
    }
}
